home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
video
/
zapem-0.000
/
zapem-0
/
zapem
/
Keyboard.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-06
|
1KB
|
90 lines
/* Copyright Alex Hornby 1994/1995. All rights reserved.
See file README for details
*/
/* This really needs improving, until it is I recommend joystick
control.
*/
#include <iostream.h>
#include <vga.h>
#include "Keyboard.h"
Keyboard::Keyboard() : Control()
{
//calibrate();
left='z';right='x';up=';';down='.';fire1=' ';
}
int
Keyboard::getkey(void)
{
int k=-1,j=25;
while(k==-1)
k=vga_getkey();
while(j!=-1)
j=vga_getkey();
return k;
}
void
Keyboard::calibrate(void)
{
cout << "Press key for LEFT\n";
left=getkey();
cout << "Press key for RIGHT\n";
right=getkey();
cout << "Press key for UP\n";
up=getkey();
cout << "Press key for DOWN\n";
down=getkey();
cout << "Press key for FIRE1\n";
fire1=getkey();
cout << "Press key for FIRE2\n";
fire2=getkey();
}
void
Keyboard::fetch(void)
{
static int scount;
int key=vga_getkey();
if(key==0)
{
if(scount>1)
{
scount=0;
for(int i=0;i<FIRE4;i++)
last[i]=false;
last[STRAIGHT]=true;
}
else
scount++;
}
else
{
scount=0;
for(int i=0;i<FIRE4;i++)
last[i]=false;
if(key==right)
last[RIGHT]=true;
else if(key==left)
last[LEFT]=true;
else if(key==down)
last[DOWN]=true;
else if(key==up)
last[UP]=true;
else if(key==fire1)
last[FIRE1]=true;
else if(key==fire2)
last[FIRE2]=true;
else if(key==fire3)
last[FIRE4]=true;
else if(key==fire4)
last[FIRE4]=true;
else if(key==27)
last[QUIT]=true;
}
}